package leetcode.L500;

import java.util.Arrays;
import java.util.Comparator;
import java.util.LinkedList;

public class EX406 {
    public static void main(String[] args) {
        int[][] people = {{7,0},{4,4},{7,1},{5,0},{6,1},{5,2}};

        Arrays.sort(people, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if(o1[0]!=o2[0]){
                    return o2[0]-o1[0];
                }
                else {
                    return o1[1]-o2[1];
                }
                //第一个值是身高，不相等的话，就按照从高到低排序
                //第一个值相等的话，就按照第二个值从低到高排序
            }
        });

        LinkedList<int[]> list = new LinkedList<>();
        for (int i = 0; i < people.length ; i++) {
            list.add(people[i][1],people[i]);
        }

        int[][] res = list.toArray(new int[list.size()][2]);

    }
}
